﻿import requests
import json
import time
import re
import binascii
import configparser
import winsound
from string import Template

suidicookie = ''
url = 'http://101.132.138.29:82'
KEY = 'zxcvbnm,'
sd = 1
jkb = 1
cf = configparser.ConfigParser()
cf.read("config.ini")
suidicookie = cf.get("config", "suidicookie")
wangluocookie = '*'


def getsuidi():
    headers = {
        'Cookie': suidicookie,
        'Content-Type': 'application/json;charset=UTF-8'
    }
    data ='''{"page":1,"pageSize":50,"page_size":50,"alarmId":"","appName":"","startDate":"2020-05-01 06:01:11","endDate":"%s","levels":[1],"me":false,"monitorItem":"","priorities":[1,2],"receiverAccount":"","responsibleAccount":"","statuses":[1,2],"types":[1]}''' % (
        time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()))

    # print(data)
    res = requests.post(
        "https://shuidi.oppoer.me/api/alarmAggregation/searchAlarmAggregations",
        data, headers=headers)
    suidihtml = res.text
    # print(suidihtml)

    postdata = {'t': time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()), 's': suidihtml}
    requests.post(url + '/shuidi/gaojing', data=postdata)

    print('正常')

    # winsound.Beep(1500, 1000)


while True:
    getsuidi()
    time.sleep(1)
